<?php
/**
 * Entry point of this page
 */
session_start();
include_once("../config.inc.php");
include_once (CMS_ROOT . 'content/lib/cms_loader.class.php');
//If session is not set then load login page again
if(!isset($_SESSION['username'])){
        $oViewmanager = Viewmanager::getInstance();
        
        $oViewmanager->_setLayout('cms_login');
        $oViewmanager->_setCSS('cms_login'); 
        Router::route($_GET); 
        $oViewmanager->load();

//If session is set load views and set templates
}else {
                   
                    $oViewmanager = Viewmanager::getInstance();

                     if (isset($_GET['a'])){ 
       if($_GET['a']== 'ajax'){
            Router::route($_GET);
           }
   }else{
                    //set the layout of the page with the viewmanager
                    $oViewmanager->_setLayout(CMS_LAYOUT);
                    $oViewmanager->_setCSS(CMS_CSS); 
                    Router::route($_GET); 
                    $oViewmanager->load();
   }
                 
}
/**
 * Overwrites the autoload function 
 * @param string class name
 */
function __autoload($sClassName){
        Loader::loadClass($sClassName);
    }
?>